import sys
import fileinput
print(sys.argv)
argc = len(sys.argv)
if argc < 2:
	print("请输入正确的参数")
	sys.exit()

#file_handler = open("/Users/donald/Library/Rime/zrm2000y.super.dict.yaml","a")
#file_handler.write(sys.argv[1]+"	"+sys.argv[2]+"\n")
#file_handler.close()
#file_dict = open("/Users/donald/Library/Rime/zrm2000t.yaml","r");
file_handler = open("/Users/donald/Library/Rime/zrm2000y.super.dict.yaml","a")
dict_set = {}
for line in fileinput.input("/Users/donald/Library/Rime/zrm2000t.yaml"):
	slist = line.split('\t')
	if(len(slist)!=2):
		continue
	dict_set[slist[0]] = slist[1]
print(type(dict_set))
for i in range(1,argc):
	tmp = ""
	not_found = False
	for a in sys.argv[i]:
		if a in dict_set:
			tmp = tmp + dict_set[a][0:2]
		else:
			not_found = True
			print(sys.argv[i],"中的",a,"在字典里不存在")
			break
	if not_found:
		pass
	else:
		print(sys.argv[i],":",tmp)
		file_handler.write(sys.argv[i]+"	"+tmp+"\n")

file_handler.close()